<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>管理接口 - QuickServer Documents</title>
  

  <link rel="shortcut icon" href="../img/favicon.ico">

  
  <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'>

  <link rel="stylesheet" href="../css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../css/theme_extra.css" type="text/css" />
  <link rel="stylesheet" href="../css/highlight.css">

  <script src="../js/jquery-2.1.1.min.js"></script>
  <script src="../js/modernizr-2.8.3.min.js"></script>
  <script type="text/javascript" src="../js/highlight.pack.js"></script>
  <script src="../js/theme.js"></script> 

  
</head>

<body class="wy-body-for-nav" role="document">

  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
      <div class="wy-side-nav-search">
        <a href="../index.html" class="icon icon-home"> QuickServer Documents</a>
        
      </div>

      <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
      <ul class="current">
    
        
            <li class="toctree-l1 ">
                <a class="" href="../index.html">Home</a>
                
            </li>
        

    
        
            <li class="toctree-l1 ">
                <a class="" href="../intro/index.html">介绍</a>
                
            </li>
        

    
        
            <li class="toctree-l1 ">
                <a class="" href="../install/index.html">安装 Quick Server</a>
                
            </li>
        

    
        
            <li class="toctree-l1 ">
                <a class="" href="../config/index.html">配置 Quick Server</a>
                
            </li>
        

    
        
            <li class="toctree-l1 current">
                <a class="current" href="index.html">管理接口</a>
                
                    <ul>
                    
                        <li class="toctree-l3"><a href="#quick-server">Quick Server 管理接口使用</a></li>
                        
                            <li><a class="toctree-l4" href="#_1">监控接口</a></li>
                        
                    
                    </ul>
                
            </li>
        

    
        
            <li class="toctree-l1 ">
                <a class="" href="../changelog/index.html">Change Log</a>
                
            </li>
        

    
        
            <li class="toctree-l1 ">
                <a class="" href="../license/index.html">License</a>
                
            </li>
        

    
</ul>

      </div>
      &nbsp;
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
        <a href="../index.html">QuickServer Documents</a>
      </nav>

      
      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="breadcrumbs navigation">
  <ul class="wy-breadcrumbs">
    <li><a href="../index.html">Docs</a> &raquo;</li>
    
    <li>管理接口</li>
      <li class="wy-breadcrumbs-aside">
        
      </li>
  </ul>
  <hr/>
</div>
          <div role="main">
            <div class="section">
              <h1 id="quick-server">Quick Server 管理接口使用</h1>
<p>Quick Server 在安装完成了之后，默认配置了一些基于 HTTP 协议的接口，主要用于 Quick Server 服务器本身的管理、维护、以及配置。这些接口的实现代码都置于 <code>apps/admin</code> 下。</p>
<p>这些接口的 HTTP URL 都是 <code>/admin</code> 。</p>
<h2 id="_1">监控接口</h2>
<p>监控接口是用于读取 Quick Server 监控数据的接口。Quick Server 的监控数据包括：进程 CPU 使用率，进程内存使用大小，进程接受的连接数。</p>
<p>action: <code>monitor.getdata</code></p>
<p>参数说明：</p>
<ul>
<li>
<p><code>time_span</code>: 指定返回最近多少时间内的数据，格式为 <code>时间长度 时间单位</code>，例如 <code>60s</code>、<code>1h</code>。如果省略该参数，那么将会针对每一个进程的每一个监控项返回所有精度的数组。</p>
<ul>
<li>如果指定的时间跨度小于 60s，那么监控数据中就只会返回 <code>last_60s</code> 这一数组，采样精度由 <code>config.monitor.interval</code> 决定；</li>
<li>如果指定的时间跨度大于60s，但是小于1小时也就是3600s，那么就只会返回 <code>last_hour</code> 这一数组，精度为1分钟；</li>
<li>如果指定的时间间隔大于3600s，那么只会返回 <code>last_day</code> 这一数组，精度为1小时。</li>
</ul>
</li>
</ul>
<p>返回值说明（JSON 字符串）：</p>
<div class="codehilite"><pre><span class="p">{</span>
    <span class="err">//</span> <span class="err">主机监控程序采样间隔，即</span> <span class="err">config.monitor.interval</span> <span class="err">的值，单位秒</span>
    <span class="nt">&quot;interval&quot;</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span>
    <span class="err">//</span> <span class="err">主机</span> <span class="err">cpu</span> <span class="err">核心数量</span>
    <span class="nt">&quot;cpu_cores&quot;</span><span class="p">:</span> <span class="s2">&quot;2&quot;</span><span class="p">,</span>
    <span class="err">//</span> <span class="err">主机物理内存，单位</span> <span class="err">kb</span>
    <span class="nt">&quot;mem_total&quot;</span><span class="p">:</span> <span class="s2">&quot;2049988&quot;</span><span class="p">,</span>
    <span class="err">//</span> <span class="err">主机空闲物理内存，</span> <span class="err">单位</span> <span class="err">kb</span>
    <span class="nt">&quot;mem_free&quot;</span><span class="p">:</span> <span class="s2">&quot;119988&quot;</span><span class="p">,</span>
    <span class="err">//</span> <span class="err">主机硬盘空间，</span> <span class="err">单位</span> <span class="err">kb</span>
    <span class="nt">&quot;disk_total&quot;</span><span class="p">:</span> <span class="s2">&quot;393838972&quot;</span><span class="p">,</span>
    <span class="err">//</span> <span class="err">主机空闲磁盘空间，</span> <span class="err">单位</span> <span class="err">kb</span>
    <span class="nt">&quot;disk_free&quot;</span><span class="p">:</span> <span class="s2">&quot;340386420&quot;</span><span class="p">,</span>

    <span class="err">//</span> <span class="err">进程名称,</span> <span class="err">nginx</span> <span class="err">master</span> <span class="err">进程</span>
    <span class="nt">&quot;NGINX_MASTER&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="err">//</span> <span class="err">监控项目名称，</span> <span class="err">该项为</span> <span class="err">cpu</span> <span class="err">使用率</span>
        <span class="nt">&quot;cpu&quot;</span><span class="p">:</span> <span class="p">{</span>
            <span class="err">//</span> <span class="err">根据</span> <span class="err">time_span</span> <span class="err">参数返回以下三种精度的数据之一</span>
            <span class="nt">&quot;last_60s&quot;</span><span class="p">:</span> <span class="p">[</span> <span class="err">//</span> <span class="err">最近</span><span class="mi">60</span><span class="err">s数据，</span> <span class="err">根据上述采样间隔采样</span>
                <span class="s2">&quot;0.2&quot;</span><span class="p">,</span>
                <span class="s2">&quot;0.2&quot;</span><span class="p">,</span>
                <span class="s2">&quot;0.2&quot;</span><span class="p">,</span>
                <span class="s2">&quot;0.2&quot;</span><span class="p">,</span>
            <span class="p">],</span>
            <span class="nt">&quot;last_hour&quot;</span><span class="p">:</span> <span class="p">[</span> <span class="err">//</span> <span class="err">最近</span><span class="mi">1</span><span class="err">小时数据，</span> <span class="mi">1</span><span class="err">分钟间隔采样</span>
            <span class="p">],</span>
            <span class="nt">&quot;last_day&quot;</span><span class="p">:</span> <span class="p">[</span> <span class="err">//</span> <span class="err">最近</span><span class="mi">1</span><span class="err">天数据，</span> <span class="mi">1</span><span class="err">小时间隔采样</span>
            <span class="p">]</span>
        <span class="p">},</span>

        <span class="err">//</span> <span class="err">监控项目，当前进程的内容使用，单位</span> <span class="err">KB</span>
        <span class="nt">&quot;mem&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="p">},</span>

        <span class="err">//</span> <span class="err">nginx</span> <span class="err">当前总的连接数</span>
        <span class="nt">&quot;conn_num&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="p">}</span>
    <span class="p">},</span>

    <span class="err">//</span> <span class="err">Nginx</span> <span class="err">Worker</span> <span class="err">进程的数据</span>
    <span class="nt">&quot;NGINX_WORKER_#1&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="nt">&quot;cpu&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="p">},</span>
        <span class="nt">&quot;mem&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="p">}</span>
    <span class="p">},</span>

    <span class="err">//</span> <span class="err">Redis</span> <span class="err">进程的数据</span>
    <span class="nt">&quot;REDIS_SERVER&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="nt">&quot;cpu&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="p">},</span>
        <span class="nt">&quot;mem&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="p">},</span>
        <span class="nt">&quot;conn_num&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="p">}</span>
    <span class="p">},</span>

    <span class="err">//</span> <span class="err">Beanstalkd</span> <span class="err">进程的数据</span>
    <span class="nt">&quot;BEANSTALKD&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="nt">&quot;cpu&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="p">},</span>
        <span class="nt">&quot;total_jobs&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>


<h3 id="_2">调用示例</h3>
<p>采用 <code>curl</code> 工具调用该接口的示例如下:</p>
<div class="codehilite"><pre><span class="nv">$ </span>curl <span class="s2">&quot;http://quick_server_host:port/admin&quot;</span> <span class="se">\</span>
       -d <span class="s2">&quot;action=monitor.getdata&amp;time_span=5m&quot;</span>
</pre></div>
            </div>
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="../changelog/index.html" class="btn btn-neutral float-right" title="Change Log"/>Next <span class="icon icon-circle-arrow-right"></span></a>
      
      
        <a href="../config/index.html" class="btn btn-neutral" title="配置 Quick Server"><span class="icon icon-circle-arrow-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
    <!-- Copyright etc -->
    </p>
  </div>

  Built with <a href="http://www.mkdocs.org">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
	  
        </div>
      </div>

    </section>

  </div>

<div class="rst-versions" role="note" style="cursor: pointer">
    <span class="rst-current-version" data-toggle="rst-current-version">
        
      <span><a href="../config/index.html" style="color: #fcfcfc;">&laquo; Previous</a></span>
      <span style="margin-left: 15px"><a href="../changelog/index.html" style="color: #fcfcfc">Next &raquo;</a></span>
    </span>
</div>

<!--
MkDocs version  : 0.12.1
Docs Build Date : 2015-04-19 02:55:50.903633
-->
</body>
</html>